export function spawnID(){
  // 生成临时ID
  var timestamp = new Date().getTime();
  var rand_str = '';
  for (;rand_str.length < 6;) {
    var rand_num = Math.round(Math.random()*25 + 65);
    rand_str += String.fromCharCode(rand_num);
  }
  return timestamp + rand_str;
}

export function getLocalID(key){
  let client_log = localStorage.getItem(key);
      console.log(client_log,'local情况');
      // 判断信息是否存在
      if (!client_log) {
        // 生成id
        let id = spawnID();
        console.log('生成Id',id);
        localStorage.setItem(key,id);
        return id
      }else{
        // 存入vue变量
        return client_log
      }
}

export function cookieValidCheck(info,client_id){
  var local_time = new Date();
  var end_time =new Date(info['endTime']);
  if (local_time > end_time) {
    return '自动登录已过期'
  }
  if (client_id != info['clientid']){
    return '自动登录失败，客户端Id不一致'
  }
  return false
}